<!DOCTYPE html>
<html lang="en">

<head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
      <script src="../../vue.js"></script>
</head>

<style>

      #pdiv{

            background-color: aqua;
      }

</style>

<body>

      <div id="app">
            <input @keyup.enter="addItem" />
            <ul>
                  <li v-for="item in arr">{{item}}</li>
            </ul>

            <div @click.self="parentTest" id="pdiv">
                  <button @click="test">按钮</button>
                   <a @click.prevent.stop href="http://www.baidu.com">miaov</a>
            </div>

      </div>




      <script>
            /*
                                                                        v-on 绑定事件
                                                                              简写为@
                                                                        事件修饰符
                                                                              v-on:click.修饰符 = '表达式'
                                                
                                                                        按键修饰符：
                                                                              .enter
                                                                              .tab
                                                                              .delete (捕获“删除”和“退格”键)
                                                                              .esc
                                                                              .space
                                                                              .up
                                                                              .down
                                                                              .left
                                                                              .right
                                                                              .数字（keyCode）
                                                
                                                                  */

            new Vue({
                  el: '#app',
                  data: {
                        arr: [1, 2, 3]
                  },
                  methods: {
                        addItem(ev) {
                              this.arr.push(ev.target.value)
                              ev.target.value = '';

                        },
                        parentTest() {

                              console.log('parentTest');
                        },
                        test(ev) {
                              console.log('test');

                              ev.stopPropagation();
                        }
                  }
            })
      </script>

</body>

</html>